/*
 * How to build:
 *   make pythino CFLAGS='-I/usr/include/python2.6' LDFLAGS='-lpython'
 */

#include <Python.h>

int
main(int argc, char *argv[])
{
	char line[BUFSIZ];
	FILE *f;
	int status = 0;

	Py_Initialize();
	/* Py_Main(argc, argv); */

	if (argc > 1) {
		f = fopen(argv[1], "r");
		if (f == NULL) {
			printf("can't open file %s\n", argv[1]);
			status = 1;
		}
		PyRun_SimpleFile(f, argv[1]);
	} else {
		while (1) {
			fputs("> ", stdout);
			fgets(line, BUFSIZ, stdin);
			if (feof(stdin) ||line == NULL)
				break;
			PyRun_SimpleString(line);
		}
	}
	
	Py_Finalize();
	return status;
}
